<template>
  <div class="pagination">
    <!--
        page-size 每页显示的条目数
        total: 总条目数
        current-page 当前页码
        layout 组件布局， 子组件名用逗号分隔  String
        page-sizes 每页显示个数选择器选项 number[] - [10,20,30,40,50,100]
    -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-size="pageSize"
      layout="total, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    total: {
      type: Number,
      default: 100,
    },
    pageSize: {
      type: Number,
      default: 10,
    },
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.$emit('CurrentChange',val)
    },
  },
  data() {
    return {
      currentPage: 1,
    };
  },
};
</script>

<style lang="less" scoped>
.pagination {
  padding: 10px;
}
</style>